package org.easypool;

import java.sql.Connection;


public class DBPool {

    private PoolDataSource poolDataSource = null;

    /**
     * 与spring整合的时候 需要把bean的作用域设置为单例
     *
     * @param config
     */
    public DBPool(DataSourceConfig config) {
        poolDataSource = new PoolDataSource(config);
    }

    public Connection getConnection() {
        Connection connection = null;
        try {
            connection = this.poolDataSource.getConnection();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return connection;
        }
    }

}
